g_autofree char *section = NULL;
g_autofree char *key = NULL;
g_autoptr(GKeyFile) config = NULL;
+ int correct_argc;
context = g_option_context_new ("(get KEY|set KEY VALUE|unset KEY)");
op = argv[1];
+ if (!strcmp (op, "set"))
+ correct_argc = 4;
+ else
+ correct_argc = 3;
+
+ if (argc > correct_argc)
+ {
+ ot_util_usage_error (context, "Too many arguments given", error);
+ return FALSE;
+ }
+
if (!strcmp (op, "set"))
{
if (opt_group)
assert_file_has_content list.txt "Flathub"
assert_file_has_content list.txt "true"
assert_file_has_content list.txt "http://example.com/ostree/repo/"
+
+# Check that it errors out if too many arguments are given
+if ${CMD_PREFIX} ostree config --repo=repo get --group=core lock-timeout-secs extra 2>err.txt; then
+ assert_not_reached "ostree config get should error out if too many arguments are given"
+fi
+assert_file_has_content err.txt "error: Too many arguments given"
echo "ok config get"
${CMD_PREFIX} ostree config --repo=repo set core.mode bare-user-only
assert_file_has_content repo/config "Nightly Flathub"
assert_file_has_content repo/config "false"
assert_file_has_content repo/config "http://example.com/ostree/"
+
+# Check that it errors out if too many arguments are given
+if ${CMD_PREFIX} ostree config --repo=repo set --group=core lock-timeout-secs 120 extra 2>err.txt; then
+ assert_not_reached "ostree config set should error out if too many arguments are given"
+fi
+assert_file_has_content err.txt "error: Too many arguments given"
echo "ok config set"
# Check that "ostree config unset" works
# Check that the key doesn't need to exist
${CMD_PREFIX} ostree config --repo=repo set --group='remote "aoeuhtns"' 'xa.title-is-set' 'false'
${CMD_PREFIX} ostree config --repo=repo unset --group='remote "aoeuhtns"' 'xa.title'
+
+# Check that it errors out if too many arguments are given
+if ${CMD_PREFIX} ostree config --repo=repo unset core.lock-timeout-secs extra 2>err.txt; then
+ assert_not_reached "ostree config unset should error out if too many arguments are given"
+fi
+assert_file_has_content err.txt "error: Too many arguments given"
echo "ok config unset"